// 生成随机数
const randomNumber = function(length) {
    var data = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l', 'A', 'S', 'D', 'F', 'G', 'H', 'J', 'K', 'L']
    var result = ''
    for (var i = 0; i < length; i++) {
        var number = Math.floor(Math.random() * 28)
        result += data[number]
    }
    return result
}
const timestampToTime = function(timestamp) {
    var date = new Date(timestamp)
    var year = date.getFullYear() + '-'
    var month =
        (date.getMonth() + 1 < 10 ?
            '0' + (date.getMonth() + 1) :
            date.getMonth() + 1) + '-'
    var day = (date.getDate() < 10 ? '0' + date.getDate() : date.getDate()) + ' '
    var h = (date.getHours() < 10 ? '0' + date.getHours() : date.getHours()) + ':'
    var m = (date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes()) + ':'
    var s = (date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds())
    var currentdate = year + month + day + h + m + s
    return currentdate
}
const nothmsTimestampToTime = function(timestamp) {
    var date = new Date(timestamp)
    var year = date.getFullYear() + '-'
    var month =
        (date.getMonth() + 1 < 10 ?
            '0' + (date.getMonth() + 1) :
            date.getMonth() + 1) + '-'
    var day = (date.getDate() < 10 ? '0' + date.getDate() : date.getDate()) + ' '
    var currentdate = year + month + day
    return currentdate
}
export default {
    randomNumber,
    timestampToTime,
    nothmsTimestampToTime
}
